package app.fugema.shop.main.order.adapter;

import com.base.common.utils.UIUtils;
import com.base.common.view.adapter.ada.SingleRecyclerAdapter;
import com.base.common.view.adapter.connector.BaseViewHolder;

import app.fugema.shop.R;
import app.fugema.shop.databinding.ShoppingCartItemBinding;
import app.fugema.shop.main.order.model.ShopCartProduct;

public class ShoppingCartAdapter extends SingleRecyclerAdapter<ShopCartProduct, ShoppingCartItemBinding>
{

    @Override
    public int getLayoutId()
    {
        return R.layout.shopping_cart_item;
    }

    @Override
    public void onBindViewHolder(ShoppingCartItemBinding binding, int position, BaseViewHolder viewHolder, ShopCartProduct bean)
    {
        super.onBindViewHolder(binding, position, viewHolder, bean);
        StringBuffer specSb = new StringBuffer();
        if(UIUtils.isNotEmpty( bean.getSize() ))
        {
            specSb.append( bean.getSizeAlias() ).append(":").append(bean.getSize()).append(" ");
        }
        if(UIUtils.isNotEmpty( bean.getColor() ))
        {
            specSb.append( bean.getColorAlias() ).append(":").append(bean.getColor()).append(" ");
        }
        if(UIUtils.isNotEmpty( bean.getVersion() ))
        {
            specSb.append( bean.getVersionAlias() ).append(":").append(bean.getVersion());
        }
        binding.rtvSpec.setText( specSb.toString() );
    }
}
